package com.ruoyi.web.controller.system;

import java.util.List;
import org.springframework.security.access.prepost.PreAuthorize;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.PutMapping;
import org.springframework.web.bind.annotation.DeleteMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
import com.ruoyi.common.annotation.Log;
import com.ruoyi.common.core.controller.BaseController;
import com.ruoyi.common.core.domain.AjaxResult;
import com.ruoyi.common.enums.BusinessType;
import com.ruoyi.system.domain.BieAlarmRecords;
import com.ruoyi.system.service.IBieAlarmRecordsService;
import com.ruoyi.common.utils.poi.ExcelUtil;
import com.ruoyi.common.core.page.TableDataInfo;

/**
 * 报警记录Controller
 * 
 * @author zxl
 * @date 2021-05-03
 */
@RestController
@RequestMapping("/system/alarm_records")
public class BieAlarmRecordsController extends BaseController
{
    @Autowired
    private IBieAlarmRecordsService bieAlarmRecordsService;

    /**
     * 查询报警记录列表
     */
    @PreAuthorize("@ss.hasPermi('system:alarm_records:list')")
    @GetMapping("/list")
    public TableDataInfo list(BieAlarmRecords bieAlarmRecords)
    {
        startPage();
        List<BieAlarmRecords> list = bieAlarmRecordsService.selectBieAlarmRecordsList(bieAlarmRecords);
        return getDataTable(list);
    }

    /**
     * 导出报警记录列表
     */
    @PreAuthorize("@ss.hasPermi('system:alarm_records:export')")
    @Log(title = "报警记录", businessType = BusinessType.EXPORT)
    @GetMapping("/export")
    public AjaxResult export(BieAlarmRecords bieAlarmRecords)
    {
        List<BieAlarmRecords> list = bieAlarmRecordsService.selectBieAlarmRecordsList(bieAlarmRecords);
        ExcelUtil<BieAlarmRecords> util = new ExcelUtil<BieAlarmRecords>(BieAlarmRecords.class);
        return util.exportExcel(list, "报警记录数据");
    }

    /**
     * 获取报警记录详细信息
     */
    @PreAuthorize("@ss.hasPermi('system:alarm_records:query')")
    @GetMapping(value = "/{recordsId}")
    public AjaxResult getInfo(@PathVariable("recordsId") String recordsId)
    {
        return AjaxResult.success(bieAlarmRecordsService.selectBieAlarmRecordsById(recordsId));
    }

    /**
     * 新增报警记录
     */
    @PreAuthorize("@ss.hasPermi('system:alarm_records:add')")
    @Log(title = "报警记录", businessType = BusinessType.INSERT)
    @PostMapping
    public AjaxResult add(@RequestBody BieAlarmRecords bieAlarmRecords)
    {
        return toAjax(bieAlarmRecordsService.insertBieAlarmRecords(bieAlarmRecords));
    }

    /**
     * 修改报警记录
     */
    @PreAuthorize("@ss.hasPermi('system:alarm_records:edit')")
    @Log(title = "报警记录", businessType = BusinessType.UPDATE)
    @PutMapping
    public AjaxResult edit(@RequestBody BieAlarmRecords bieAlarmRecords)
    {
        return toAjax(bieAlarmRecordsService.updateBieAlarmRecords(bieAlarmRecords));
    }

    /**
     * 删除报警记录
     */
    @PreAuthorize("@ss.hasPermi('system:alarm_records:remove')")
    @Log(title = "报警记录", businessType = BusinessType.DELETE)
	@DeleteMapping("/{recordsIds}")
    public AjaxResult remove(@PathVariable String[] recordsIds)
    {
        return toAjax(bieAlarmRecordsService.deleteBieAlarmRecordsByIds(recordsIds));
    }
}
